using System;
using System.Collections;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Windows.Forms;
using System.Diagnostics;
using CStock;



using CapitalReSources;


namespace CGrid
{
	/// <summary>
	/// Summary description for GridBase.
	/// </summary>
    public class GridStockData : GridShareDetails, IGridShowPortfolio
	{
		#region attributes


       
		#endregion

		#region constructor

        public GridStockData()
            : base()
		{
			
			try
			{
                

                this.mainClass = MainClass.Instance;

				this.mainClass.GridStockData = this;
				this.CreateGrid(CUtil.GridTypes.StockData, true);
			}
			catch(Exception ex)
			{
                System.Diagnostics.Debug.WriteLine("Error in creating Stock Data Grid" + ex.Message);
			}
			

			
			

		}

		/// <summary> 
		/// Clean up any resources being used.
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			
			base.Dispose( disposing );
		}
		#endregion



		#region methods
        public IPortfolio PortfolioPrevious;

		public new void ShowPortfolio(IPortfolio port)
		{
            if (PortfolioPrevious == null || PortfolioPrevious != port)
            {
                PortfolioPrevious = port;
                this.ClearGridRows();
                for (int i = 0; i < port.DataItems.Count; i++)
                {
                    IDataItem di = port.DataItems[i];
                    this.AddRow_Single(di, true);
                }
            }
            else
            {
                PortfolioPrevious = port;
                this.ClearGridRows();
                for (int i = 0; i < port.DataItems.Count; i++)
                {
                    IDataItem di = port.DataItems[i];
                    this.AddRow_Single(di, true);
                }

              
            }

            this.RefreshGrid();

		}

		#endregion

	
	}
}
